﻿using DataRepositoryLayer.Interfaces;
using ModelLayer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataRepositoryLayer.Classes
{
    public class BatteryTypeRepository : GenericDataRepository<BatteryType>, IBatteryTypeRepository
    {
        public BatteryTypeRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
        {

        }

        public BatteryType GetByIdWithRowlock(int id)
        {
            context.Database.ExecuteSqlCommand("SELECT NULL FROM BatteryType WITH(ROWLOCK, XLOCK) WHERE id = " + id);
            return GetSingle(bt => bt.id == id);
        }


        public BatteryType GetById(int id)
        {
            return GetSingle(bt => bt.id == id);
        }

        public IList<BatteryType> GetAllForManagementSystem()
        {
            return GetAll(p => p.Pricings);
        }
    }
}
